<template>
	<view class="login">
		<view class="login-top">
			<image src="/static/image/logo.png" mode=""></image>
		</view>
		<view class="login-cencer">
			<view class="login-phone">
				<text>+86</text>
				<view class="login-input">
					<input type="text" v-model="phoneValue" placeholder="输入手机号" />
				</view>
			</view>
			<view class="login-phone">
				<view class="login-input">
					<input type="text" v-model="passwordValue" placeholder="输入密码" />
				</view>
			</view>
			<view class="login-sp">
				<view class="zhuce" @click="register">
					<text>用户注册</text>
				</view>
				<view class="wangji" @click="forget">
					<text>忘记密码</text>
				</view>
			</view>
		</view>
		<view class="login-bottom">
			<view class="bottom">
				<view class="bou" @click="login">
					<button type="primary" :disabled="loginClick">登录</button>
				</view>
			</view>
			<view class="login-radio">
				<view class="radio">
					<radio>
						我已阅读并同意《用户服务协议及隐私政策》
					</radio>
				</view>
			</view>
		</view>
		<view class="wxlogin">
			<view class="wx">
				<view class="xian"></view>
				<view class="login-qi">
					<text>其他登录方式</text>
				</view>
				<view class="xian"></view>
			</view>
			<view class="wx-image" @click="weixinLogin">
				<image src="/static/image/weix-icon.png" mode=""></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phoneValue: '', //手机号
				passwordValue: '', //密码
			}
		},
		computed: {
			loginClick() {
				return this.phoneValue && this.passwordValue == '';
			}
		},
		methods: {
			weixinLogin() {
				let that = this;
				uni.getProvider({
					service: 'oauth',
					success: function(res) {
						console.log(res, "}")
						//支持微信、qq和微博等
						if (~res.provider.indexOf('weixin')) {
							uni.login({
								provider: 'weixin',
								success: function(loginRes) {
									// 获取用户信息
									uni.getUserInfo({
										provider: 'weixin',
										success: function(infoRes) {
											console.log(JSON.stringify(infoRes.userInfo));
										}
									});
									console.log(loginRes, loginRes.code, "|loginRes")
									// let params = {
									// 	access_token: loginRes.authResult.access_token
									// }
									// this.$post(this.api.wechat_login, params).then((res) =>{
									// 	console.log(res)
									// }).catch((err) =>{console.log(err)})
									// 						that.$queue.showLoading('正在登录中...');
									// 						console.error(loginRes.authResult);
									// //获取登录的token
									// that.$queue.setData('weixinToken',loginRes.authResult.access_token);
									// //获取登录的unionid 这个还是在开放平台做了 公众号 小程序 微信登录app关联才会有
									// 						that.$queue.setData('unionid', loginRes.authResult.unionid);
									// //获取openid
									// 						that.$queue.setData('weixinOpenid', loginRes.authResult.openid);
									// //这里吧数据全部提交给后台核验，有没有注册 注册了 后台代码会请求接口String s = HttpClient.doGet("https://api.weixin.qq.com/sns/userinfo?access_token=" + loginInfo.getToken() + "&openid=" + loginInfo.getOpenid()); 获取头像和昵称
									// 	// 					that.$Request
									// 	// 						.postJson('/user/loginApp', {
									// 	// 							token: loginRes.authResult.access_token,
									// 	// 							unionid: loginRes.authResult.unionid,
									// 	// 							openid: loginRes.authResult.openid
									// 	// 						})
									// 	// 						.then(res => {
									// 	// 							if (res.status === 0) {

									// 	// 								//绑定手机号直接登录
									// 	// 								that.getUserInfo(res.data.userId, res.data.uuid);
									// 	// 							} else {
									// 	// 								//没有绑定手机号让绑定手机号
									// 	// 								uni.navigateTo({
									// 	// 									url: '/pages/public/wxmobile'
									// 	// 								});
									// 	// 							}
									// 	// 						});
								}
							});
						}
					}
				});
			},
			//忘记密码
			forget() {
				uni.navigateTo({
					url: '/pages/bootpage/forgetpassword'
				})
			},
			//注册
			register() {
				uni.navigateTo({
					url: '/pages/bootpage/register'
				})
				// console.log("555")
				// uni.request({
				//     url:'http://pv.sohu.com/cityjson?ie=utf-8',
				// 	method:'POST',
				// 	success: (res) => {
				//         console.log(res, "res")
				// 	},
				// 	fail(err) {
				// 		console.log(err,"err")
				// 	}
				// })
			},
			// 登录
			login() {
				// if() {}
				let params = {
					mobile: '15063335547',
					password: '123456',
				}
				this.$post(this.api.login, params).then((res) => {
						console.log(res);
					}).catch((err) => {
						console.log(err)
					}),
					//登录跳转
					// uni.switchTab({
					// 	url: '/pages/index/index',
					// });
					console.log("显示");
			}
		}
	}
</script>

<style lang="less" scoped>
	.login {
		.login-top {
			width: 750rpx;
			height: 350rpx;

			image {
				width: 123rpx;
				height: 163rpx;
				position: relative;
				left: 50%;
				top: 50%;
				transform: translate(-50%, -10%);
			}
		}

		.login-cencer {
			margin: 0 auto;
			margin-top: 20rpx;
			width: 600rpx;

			.login-phone {
				height: 80rpx;
				display: flex;
				margin-top: 20rpx;
				border-bottom: 1rpx solid #E0E0E0;

				/*上下  */
				text {
					font-size: 32rpx;
					font-family: Arial;
					font-weight: 400;
					color: #333333;
					width: 70rpx;
					display: flex;
					justify-content: center;
					flex-direction: column;
					border-right: 1rpx solid #E0E0E0;
				}

				.login-input {
					display: flex;
					justify-content: center;
					flex-direction: column;

					input {
						font-size: 32rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #999999;
						display: flex;
						justify-content: center;
						flex-direction: column;
						margin-left: 30rpx;
					}
				}
			}

			.login-sp {
				margin-top: 30rpx;
				display: flex;
				justify-content: space-between;

				.zhuce {
					font-size: 24rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #20A4FB;
				}

				.wangji {
					font-size: 24rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #999999;
				}
			}
		}

		.login-bottom {
			margin-top: 80rpx;

			.bottom {
				.bou {
					width: 569rpx;
					height: 80rpx;
					background: linear-gradient(90deg, #2EA7E0 0%, #0099FF 100%);
					border-radius: 13rpx;
					margin: 0 auto;
					text-align: center;
					line-height: 80rpx;

					button {
						width: 569rpx;
						height: 80rpx;
						background: linear-gradient(90deg, #2EA7E0 0%, #0099FF 100%);
						border-radius: 13rpx;
						font-size: 28rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #FFFFFF;
					}
				}
			}

			.login-radio {
				width: 530rpx;
				margin: 0 auto;
				margin-top: 30rpx;
				white-space: nowrap;

				.radio {
					font-size: 24rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					margin: 0 auto;
					color: #999999;
				}
			}

		}

		.wxlogin {
			margin-top: 200rpx;
			width: 750rpx;
			height: 160rpx;

			.wx {
				width: 600rpx;
				height: 40rpx;
				margin: 0 auto;
				display: flex;

				.xian {
					width: 200rpx;
					height: 1rpx;
					background: black;
					margin-top: 20rpx;
				}

				.login-qi {
					line-height: 40rpx;
					white-space: nowrap;
					margin: 0 20rpx 0 20rpx;

					text {
						font-size: 24rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #999999;
					}
				}
			}

			.wx-image {
				width: 97rpx;
				margin: 0 auto;
				margin-top: 20rpx;

				image {
					width: 97rpx;
					height: 97rpx;
				}
			}
		}
	}
</style>
